class Complex {
   public var radius:Number;
   public var angle:Number;
   public function Complex(ar:Number,aa:Number):void {
      radius = ar;
      angle = aa;
   }

   public function set imaginary(newImaginary:Number):void 
   {
      var oldReal = this.real;
      angle = Math.atan(newImaginary/oldReal);
      radius = Math.sqrt(oldReal*oldReal + newImaginary*newImaginary);
   }
   public function get imaginary():Number
   {
          return radius*Math.sin(angle);
   }

   public function set real(newReal:Number):void 
   {
      var oldImaginary = this.real;
      angle = Math.atan(oldImaginary/newReal);
      radius = Math.sqrt(newReal*newReal + oldImaginary*oldImaginary);
   }
   public function get real():Number
   {
          return radius*Math.cos(angle);
   }



}

var p1 = new Complex(2,3.14/2);
print("Before");
print(p1.angle);
print(p1.radius);
print(p1.imaginary);
print(p1.real);

p1.real = 5;
p1.imaginary = 5;

print("After");
print(p1.angle);
print(p1.radius);
print(p1.imaginary);
print(p1.real);
